<include file="public@header"/>

<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('StudentScore/index')}">学生成绩列表</a></li>
        <li class="active"><a href="javascript:;">编辑</a></li>
    </ul>
    <div class="row margin-top-20">
        <div class="col-md-10 col-md-offset-2">
            <form action="{:url('StudentScore/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
                <input type="hidden" name="is_teacher" value="{$is_teacher}">
                <input type="hidden" name="id" value="{$data->id}">
                <input type="hidden" name="class_id" value="{$data->class_id}">
                <input type="hidden" name="student_id" value="{$data->student_id}">
                <div class="row">
                    <div class="col-md-9">
                        <table class="table table-bordered chase_classroom_table">
                            <tr>
                                <th>学校<span class="form-required">*</span></th>
                                <td>
                                    <input type="text" class="form-control col-md-4" name="school_name" value="{$data->school_name}" readonly>
                                </td>
                            </tr>
                            <tr>
                                <th>班级<span class="form-required">*</span></th>
                                <td>
                                    <input type="text" class="form-control col-md-4" name="class_name" value="{$data->class_name}" readonly>
                                </td>
                            </tr>

                            <tr>
                                <th>课程<span class="form-required">*</span></th>
                                <td>
                                    <input type="text" class="form-control col-md-4" name="course_name" value="{$data->course_name}" readonly>
                                </td>
                            </tr>
                            <tr>
                                <th>学生<span class="form-required">*</span></th>
                                <td>
                                    <input type="text" class="form-control col-md-4" name="student_name" value="{$data->student_name}" readonly>
                                </td>
                            </tr>
                            <tr>
                                <th>第一题<span class="form-required">*</span></th>
                                <td>
                                    <input type="number" class="form-control" name="question1" min="0" max="100"
                                           placeholder="请输入分数" value="{$data->question1}">
                                </td>
                            </tr>
                            <tr>
                                <th>第二题<span class="form-required">*</span></th>
                                <td>
                                    <input type="number" class="form-control" name="question2" min="0" max="100"
                                           placeholder="请输入分数" value="{$data->question2}">
                                </td>
                            </tr>
                            <tr>
                                <th>第三题<span class="form-required">*</span></th>
                                <td>
                                    <input type="number" class="form-control" name="question3" min="0" max="100"
                                           placeholder="请输入分数" value="{$data->question3}">
                                </td>
                            </tr>
                            <tr>
                                <th>第四题<span class="form-required">*</span></th>
                                <td>
                                    <input type="number" class="form-control" name="question4" min="0" max="100"
                                           placeholder="请输入分数" value="{$data->question4}">
                                </td>
                            </tr>
                            <tr>
                                <th>第五题<span class="form-required">*</span></th>
                                <td>
                                    <input type="number" class="form-control" name="question5" min="0" max="100"
                                           placeholder="请输入分数" value="{$data->question5}">
                                </td>
                            </tr>
                            <tr>
                                <th>第六题<span class="form-required">*</span></th>
                                <td>
                                    <input type="number" class="form-control" name="question6" min="0" max="100"
                                           placeholder="请输入分数" value="{$data->question6}">
                                </td>
                            </tr>
                            <tr>
                                <th>附加分<span class="form-required">*</span></th>
                                <td>
                                    <input type="number" class="form-control" name="extra_score" min="0" max="100"
                                           placeholder="请输入附加分" value="{$data->extra_score}">
                                </td>
                            </tr>
                            <tr>
                                <th>总分<span class="form-required">*</span></th>
                                <td>
                                    <input type="text" class="form-control" name="total_score" id="total_score" min="0"
                                           placeholder="请输入总分" readonly value="{$data->total_score}">
                                </td>
                            </tr>
                        </table>

                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
                                <a class="btn btn-default" href="{:url('StudentScore/index')}">{:lang('BACK')}</a>
                            </div>
                        </div>
                    </div>
                </div>
            </form>

        </div>
    </div>
</div>
<!--ajax layer 弹窗-->
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $('body').on('change','input[type=number]',function ()
        {
            var ques1 = $('input[name=question1]').val();
            var ques2 = $('input[name=question2]').val();
            var ques3 = $('input[name=question3]').val();
            var ques4 = $('input[name=question4]').val();
            var ques5 = $('input[name=question5]').val();
            var ques6 = $('input[name=question6]').val();
            var extra_score = $('input[name=extra_score]').val();

            if(typeof(ques1) == "undefined" || ques1 == ''){
                ques1 = 0.00;
            }
            if(typeof(ques2) == "undefined" || ques2 == ''){
                ques2 = 0.00;
            }
            if(typeof(ques3) == "undefined" || ques3 == ''){
                ques3 = 0.00;
            }
            if(typeof(ques4) == "undefined" || ques4 == ''){
                ques4 = 0.00;
            }
            if(typeof(ques5) == "undefined" || ques5 == ''){
                ques5 = 0.00;
            }
            if(typeof(ques6) == "undefined" || ques6 == ''){
                ques6 = 0.00;
            }
            if(typeof(extra_score) == "undefined" || extra_score == ''){
                extra_score = 0.00;
            }

            var total = Math.abs(ques1) + Math.abs(ques2) + Math.abs(ques3)+ Math.abs(ques4) +
                Math.abs(ques5) + Math.abs(ques6) + Math.abs(extra_score);
            $('#total_score').val(total.toFixed(2));
        });
    });

</script>

</body>
